include "base.thrift"
include "user.thrift"

struct Comment{
    1: i32 comment_id;
    2: i32 reply_post_id; // 必有一个值，表示一个帖子下面的一级评论或二级评论
    3: i32 reply_comment_id; //
    4: user.Member creator; // 创建人
    5: string comment; // 评论正文
    6: user.Member reply_to; // 回复的用户(帖子的主人或者发表一级评论的人)
    7: i32 comment_count; // 回复该评论的数量
    8: string created_at; // 评论的创建时间
    9: bool liked; // 点过赞了
}

struct CreateCommentResponse{
    1: base.Meta meta;
    2: Comment comment;
}

struct CreateCommentRequest{
    1: Comment comment;
}

struct GetCommentsResponse{
    1: base.Meta meta;
    2: list<Comment> comments;
}

struct GetCommentsRequest{
    1: i32 post_id; // 查询给帖子的所有评论
    2: i32 reply_comment_id; // 查询一级评论下所有的二级评论
    3: i32 limit;
    4: i32 offset;
    5: string order; // 排序方式，枚举值： "time_desc"-时间降序；"time_asc"-时间升序；"hot-desc"-热度降序
    6: i32 like_count; // 点赞数量
}

struct DeleteCommentRequest {
    1: i32 comment_id;
}

struct DeleteCommentResponse{
    1: base.Meta meta;
    2: Comment comment;
}

struct LikeCommentResponse{
    1: base.Meta meta;
}

struct LikeCommentRequest{
    1: i32 comment_id;
}

service CommentService{
    GetCommentsResponse GetComments(1: GetCommentsRequest req)(api.get="/comments")
    CreateCommentResponse CreateComment(1: CreateCommentRequest req)(api.post="/comment")
    DeleteCommentResponse DeleteComment(1: DeleteCommentRequest req)(api.delete="/comment")
}